package net.lab1024.sa.admin.module.business.sh.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.admin.module.business.order.domain.vo.OrderVO;
import net.lab1024.sa.admin.module.business.sh.domain.form.ShAddForm;
import net.lab1024.sa.admin.module.business.sh.domain.form.ShQueryForm;
import net.lab1024.sa.admin.module.business.sh.domain.form.ShUpdateForm;
import net.lab1024.sa.admin.module.business.sh.domain.vo.ShVO;
import net.lab1024.sa.admin.module.business.sh.service.ShService;
import net.lab1024.sa.admin.module.system.type.domain.TypeEntity;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 审核 Controller
 *
 * @Author syf
 * @Date 2025-06-04 14:41:53
 * @Copyright 畅想科技
 */

@RestController
@Tag(name = "")
public class ShController {

    @Resource
    private ShService shService;

    @Operation(summary = "分页查询 @author syf")
    @PostMapping("/sh/queryPage")
    public ResponseDTO<PageResult<ShVO>> queryPage(@RequestBody @Valid ShQueryForm queryForm) {
        System.out.println(queryForm);
        if (queryForm.getShType() == 0) {
            return ResponseDTO.ok(shService.queryOrderPage(queryForm));
        }else {
            return ResponseDTO.ok(shService.queryUserPage(queryForm));
        }
    }

    @Operation(summary = "添加 @author syf")
    @PostMapping("/sh/add")
    public ResponseDTO<String> add(@RequestBody @Valid ShAddForm addForm) {
        return shService.add(addForm);
    }

    @Operation(summary = "更新 @author syf")
    @PostMapping("/sh/update")
    public ResponseDTO<String> update(@RequestBody @Valid ShUpdateForm updateForm) {
        return shService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author syf")
    @PostMapping("/sh/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return shService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author syf")
    @GetMapping("/sh/delete/{shId}")
    public ResponseDTO<String> batchDelete(@PathVariable Integer shId) {
        return shService.delete(shId);
    }
}
